//
//  JGGPControlCenter.h
//  JGInputDriver
//
//  Created by jagger.tu on 2025/3/21.
//

#import <UIKit/UIKit.h>
#import <JGInputDriver/JGGamepad.h>
#import <JGInputDriver/JGThirdPartyGamepad.h>


/// 手柄控制类型
typedef NS_ENUM(NSInteger,JGGPControlType){
    /// 禁用手柄
    JGGPControlTypeDisabled = 0,
    /// 常规物理手柄
    JGGPControlTypePhysical = 1,
    /// 支持虚拟手柄
    JGGPControlTypeVirtual = 2,
    /// 使用物理手柄转键鼠
    JGGPControlTypePhysicalToKeyMouse = 3,
} ;

NS_ASSUME_NONNULL_BEGIN

@class JGGPControlCenter;

@protocol JGGPControlCenterDelegate <NSObject>

@optional

/// 手柄控制中心通知手柄插入数量改变
/// - Parameters:
///   - controlCenter: 手柄控制中心
///   - gamepadList: 改变后的手柄列表
- (void)controlCenter:(JGGPControlCenter *)controlCenter didChangeGamepadList:(NSArray<JGGamepad *> *)gamepadList;

@end

/// 手柄控制中心
@interface JGGPControlCenter : NSObject

/// 手柄控制中心代理
@property (nonatomic, weak) id<JGGPControlCenterDelegate> delegate;
///指定手柄控制类型
@property (nonatomic, assign) JGGPControlType controlType;
/// 虚拟手柄视图
@property (nonatomic, strong, readonly,nullable) UIView *virtualGamepadView;
/// 当前连接的手柄
@property (nonatomic, strong, readonly) NSArray<JGGamepad *>* currentGamepadList;
/// 控制中心
+ (instancetype)defaultInstance;
/// 安装手柄控制中心
- (void)installGameControlCenter;
/// 移除手柄控制中心
- (void)uninstallGameControlCenter;

/// 添加一个游戏手柄 -- 在收到
- (void)addGamepad:(JGGamepad *)gamepad;
/// 移除一个游戏手柄
- (void)removeGamepad:(JGGamepad *)gamepad;

/// 通知手柄震动,震动程度取决于频率,调用一次后,会逐渐衰减
/// - Parameters:
///   - slotId: 云端插槽ID
///   - left: 左马达速度
///   - right: 右马达速度
- (void)vibrationWithSlotId:(int)slotId Left:(int)left right:(int)right;

@end

NS_ASSUME_NONNULL_END
